package cn.pn.project.client.user;

import cn.pn.project.client.user.fallback.AttentionFeignFallback;
import cn.pn.project.pojo.user.Attention;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;

@FeignClient(name = "pn-user-provider", fallback = AttentionFeignFallback.class)
@RequestMapping("/attention")
public interface AttentionFeign {
    /**
     * 添加关注
     *
     * @param attention userId commodityId 必须存在
     * @return
     * @throws RuntimeException
     */
    @PostMapping("/add")
    boolean addAttention(@RequestBody Attention attention) throws RuntimeException;

    /**
     * 查询用户所有的关注
     *
     * @param attention userId 必须有
     * @return
     * @throws RuntimeException
     */
    @PostMapping("/find")
    List<Attention> findAttentionByUserIdAndStatus(@RequestBody Attention attention) throws RuntimeException;

    /**
     * 取消关注
     *
     * @param attention userId attentionId 必须有
     * @return
     * @throws RuntimeException
     */
    @PostMapping("/remove")
    boolean removeAttention(@RequestBody Attention attention) throws RuntimeException;

    /**
     * 获取指定用户的指定商品的关系数据
     *
     * @param attention userId commodityId 必须有
     * @return 返回单独（一条）的关系数据
     * @throws RuntimeException 运行时异常
     * @throws SQLException     sql异常
     */
    @PostMapping("/findAttention")
    public Attention findAttention(@RequestBody Attention attention) throws RuntimeException, SQLException;
}
